package com.wf.ew.system.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.common.ServiceSupport;
import com.wf.ew.system.biz.CompanyBiz;
import com.wf.ew.system.model.Company;
import com.wf.ew.system.model.User;
import com.wf.ew.system.service.CompanyService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2019-08-17 15:38:50
 * @version ：1.0
 */
@Service
public class CompanyServiceImpl extends ServiceSupport implements CompanyService {

	@Autowired
	private CompanyBiz companyBiz;

	@Transactional
	@Override
	public String list(PageResult<T> page, Company company, User loginUser) {
		return companyBiz.list(page,company,loginUser);
	}
	
	@Transactional
	@Override
	public List<Company> list(Company company, User loginUser) {
		return companyBiz.list(company,loginUser);
	}

	@Transactional
	@Override
	public Company getById(Company company) {
		return companyBiz.getById(company);
	}

	@Transactional
	@Override
	public JsonResult add(Company company, User loginUser) {
		if (companyBiz.add(company, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(Company company, User loginUser) {
		if (companyBiz.update(company, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(Company company, User loginUser) {
		if (companyBiz.delete(company, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
